package com.wayin.lift.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.wayin.lift.dao.PersonnelDao;
import com.wayin.lift.entity.PersonnelEntity;
import com.wayin.lift.service.PersonnelService;

import java.util.List;


@Service("personnelService")
public class PersonnelServiceImpl extends ServiceImpl<PersonnelDao, PersonnelEntity> implements PersonnelService {

    @Autowired
    private PersonnelDao personnelDao;

    @Override
    public List<PersonnelEntity> findAllPersonnel() {
        return personnelDao.selectPersonnel();
    }

    @Override
    public PersonnelEntity findByOpenId(String openId) {
        return personnelDao.selectIsHave(openId);
    }

    @Override
    public List<PersonnelEntity> findByNumber(String number) {
        return personnelDao.selectByNumber(number);
    }

    @Override
    public PersonnelEntity backLogin(String username, String password) {
        PersonnelEntity p = personnelDao.selectNameAndPwd(username, password);
        return p;
    }

    @Override
    public boolean insert(PersonnelEntity personnel) {
        if (personnelDao.insert(personnel) > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean update(PersonnelEntity personnel) {
        if (personnelDao.update(personnel) > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean updateByOpenId(PersonnelEntity personnel) {
        if (personnelDao.updateByOpenId(personnel) > 0){
            return true;
        }
        return false;
    }

}